﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.Security.Permissions;
using System.Text;

namespace MedReg.Classes
{
    [Serializable]
    public class SkillImprovement : ISerializable
    {
        private EducationInstitution organisationField;

        private string cycleField;

        private decimal hoursField;

        private decimal yearField;

        private string diplomaSerieField;

        private string diplomaNumberField;

        private System.Nullable<System.DateTime> issueDateField;

        private SertificateSpeciality educationSpecialityField;
        private Employee employeeField;

        private static readonly SkillImprovement theOneObject = new SkillImprovement();

        public static SkillImprovement GetSkillImprovement()
        {
            return theOneObject;
        }
        /// <remarks/>
        public EducationInstitution Organisation
        {
            get
            {
                return this.organisationField;
            }
            set
            {
                this.organisationField = value;
            }
        }

        /// <remarks/>
        public string Cycle
        {
            get
            {
                return this.cycleField;
            }
            set
            {
                this.cycleField = value;
            }
        }

        /// <remarks/>
        public decimal Hours
        {
            get
            {
                return this.hoursField;
            }
            set
            {
                this.hoursField = value;
            }
        }

        /// <remarks/>
        public decimal Year
        {
            get
            {
                return this.yearField;
            }
            set
            {
                this.yearField = value;
            }
        }

        /// <remarks/>
        public string DiplomaSerie
        {
            get
            {
                return this.diplomaSerieField;
            }
            set
            {
                this.diplomaSerieField = value;
            }
        }

        /// <remarks/>
        public string DiplomaNumber
        {
            get
            {
                return this.diplomaNumberField;
            }
            set
            {
                this.diplomaNumberField = value;
            }
        }

        /// <remarks/>
        [System.Xml.Serialization.XmlElementAttribute(IsNullable = true)]
        public System.Nullable<System.DateTime> IssueDate
        {
            get
            {
                return this.issueDateField;
            }
            set
            {
                this.issueDateField = value;
            }
        }

        /// <remarks/>
        public SertificateSpeciality EducationSpeciality
        {
            get
            {
                return this.educationSpecialityField;
            }
            set
            {
                this.educationSpecialityField = value;
            }
        }
        public Employee Employee
        {
            get
            {
                return employeeField;
            }
            set
            {
                employeeField = value;
            }
        }
         [SecurityPermission(SecurityAction.LinkDemand, Flags = SecurityPermissionFlag.SerializationFormatter)]
        public void GetObjectData(SerializationInfo info, StreamingContext context)
        {
          //  throw new NotImplementedException();
             info.AddValue("Organisation", organisationField);
             info.AddValue("Cycle", cycleField);
             info.AddValue("Hours", hoursField);
             info.AddValue("Year", yearField);
             info.AddValue("DiplomaSerie", diplomaSerieField);
             info.AddValue("DiplomaNumber", diplomaNumberField);
             info.AddValue("IssueDate", issueDateField);
             info.AddValue("EducationSpeciality", educationSpecialityField);
        }
        public SkillImprovement()
        {
        }
        public List<Classes.SkillImprovement> getSkillImprovementListList(Classes.ArrayOfEmployee sEmployee)
        {

            foreach (var emp in sEmployee)
            {
                foreach (var skillImprovement in emp.EmployeeSkillImprovement)
                {
                    skillImprovement.Employee = emp;
                }
            }

            //var awd = sEmployee
            //    .SelectMany(award => award.EmployeeAwards, (Employees, Awards) => new { Employees, Awards })
            //    .Select(AwardsEx => new { Employee = AwardsEx.Employees, AwardsEx.Awards }).ToList();

            var cr = sEmployee.SelectMany(em => em.EmployeeSkillImprovement).ToList();

            return cr;
        }
    }
}
